<?php
class IndexController extends Zend_Controller_Action
{
	static function initAdmin(&$p_objController)
	{
		$AppUI = Zend_Registry::get('AppUI');
		if (!$AppUI->admin_id || $AppUI->admin_id==-1)
		{
			$p_objController->_redirect(HOST_ADMIN.'/login');
		}
		
		$intMenuType	= $AppUI->_get(MENU_KEY);
		$intMenuType	= (intval($intMenuType)>0) ? $intMenuType : MENU_SYSTEM;
		
		$p_objController->view->controllerName 	= $p_objController->_request->getParam('controller');
		$p_objController->view->actionName 		= $p_objController->_request->getParam('action');
		$p_objController->view->pageRootUrl 	= HOST_ADMIN.'/'.$p_objController->view->controllerName;
		$p_objController->view->intMenuType		= $intMenuType;
		
		$p_objController->AppUI	= $AppUI;
	}
	
	public function indexAction()
	{	
		self::initAdmin($this);
	}
	
	public function changeMenuAction()
	{
		$intMenuType = $this->_request->getParam('t');
		
		$AppUI	= Zend_Registry::get('AppUI');
		$AppUI->_add(MENU_KEY, $intMenuType);
		#$AppUI->save();
		
		header('Location:'.HOST_ADMIN);
		exit;
	}
}
?>
